﻿<Window x:Class="CommunicationDesktopApplication.MainWindow"
        xmlns:ac="clr-namespace:CommunicationDesktopApplication"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Desktop Application to Control Windows Service" Height="349" Width="487" Background="Gray"   Loaded="Window_Loaded" Unloaded="Window_Unloaded" >
    <Window.Resources>
        <DataTemplate x:Key="myTaskTemplate">
            <StackPanel Orientation="Horizontal"  DataContext="{Binding}">
                <TextBlock Text="{Binding Path=ApplicationId}" Background="{Binding Path=ColorBytes, Converter={StaticResource BytesToBackground}}" DataContext="{Binding}"  />
                <Button Name="btnPing"  Click="btnPing_Click" Content="Ping" DataContext="{Binding}" IsEnabled="{Binding Path=ApplicationId,  Converter={StaticResource GuidToBoolean}}"  />
            </StackPanel>
        </DataTemplate>
        <ac:GuidToBoolean x:Key="guidToBoolean" />
        <ac:BytesToBackground x:Key="bytesToBackground" />
    </Window.Resources>
    <Grid DataContext="{Binding}">
        <Rectangle Height="49" HorizontalAlignment="Left" Margin="12,5,0,0" Name="rglColor" Stroke="Black" VerticalAlignment="Top" Width="307" />
        <Label Content="Next Check in " Height="28" HorizontalAlignment="Left" Margin="213,0,0,0" Name="lblNextUpdate" VerticalAlignment="Top" />
        <Label Content="0" Height="28" HorizontalAlignment="Left" Margin="295,0,0,0" Foreground="DarkRed" Name="lblNextUpdateValue" VerticalAlignment="Top" />
        <Label Content="00000000-0000-0000-0000-000000000000" Height="28" Margin="104,29,152,253" Name="lblAppGuid" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="10"  FontStyle="Italic" Width="208" />

        <ListBox Height="190" HorizontalAlignment="Left" Margin="12,60,0,0" Name="lbAppsRunning" VerticalAlignment="Top" Width="307"
                 ItemsSource="{Binding}" 
                 DataContext="{Binding Source={x:Static ac:DesktopApplicationConnection.AttachedApplications }}" 
                 ItemTemplate="{StaticResource myTaskTemplate}" SelectionMode="Extended"
                 />
        
        <Label Content="00000000-0000-0000-0000-000000000000" Height="24" Margin="103,256,153,30" Name="lblAppPingGuid" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="10"  FontStyle="Italic" Width="209" />
        <Label Content="App ID" Height="28" HorizontalAlignment="Left" Margin="22,26,0,0" Name="lblAppId" VerticalAlignment="Top" Width="52" />
        <Label Content="Last Pinged By" Height="28" HorizontalAlignment="Left" Margin="12,254,0,0" Name="lblAppConnectedId" VerticalAlignment="Top" Width="95" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="335,5,0,0" Name="lblHostedService" Text="Inbound service is off" VerticalAlignment="Top" Width="118" />
        <Button Content="Turn Off Inbound" Height="23" HorizontalAlignment="Left" Margin="335,63,0,0" Name="btnDisableHost" VerticalAlignment="Top" Width="118" Click="btnDisableHost_Click" />
        <Button Content="Turn On Inbound" Height="23" HorizontalAlignment="Left" Margin="335,34,0,0" Name="btnEnableHost" VerticalAlignment="Top" Width="118" Click="btnEnableHost_Click" />

        <TextBlock Height="23" HorizontalAlignment="Left" Margin="335,108,0,0" Name="lblServiceStatus" Text="Service is off" VerticalAlignment="Top" Width="118" />
        <Button Content="Turn Off Service" Height="23" HorizontalAlignment="Left" Margin="335,128,0,0" Name="btnDisableService" VerticalAlignment="Top" Width="118" Click="btnDisableService_Click" />
        <Button Content="Turn On Service" Height="23" HorizontalAlignment="Left" Margin="335,158,0,0" Name="btnEnableService" VerticalAlignment="Top" Width="118" Click="btnEnableService_Click" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="335,197,0,0" Name="lblJobStatus" Text="Job is not Running" VerticalAlignment="Top" Width="118" />
        <Button Content="Start Job" Height="23" HorizontalAlignment="Left" Margin="335,217,0,0" Name="btnStartJob" VerticalAlignment="Top" Width="118" Click="btnStartJob_Click" />
        <Button Content="Pause Job" Height="23" HorizontalAlignment="Left" Margin="335,247,0,0" Name="btnPauseJob" VerticalAlignment="Top" Width="118" Click="btnPauseJob_Click" />
       
    </Grid>
</Window>
